package com.hayrullah.cinema.Dao;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;

import com.hayrullah.cinema.Util.HibernateUtil;
import com.hayrullah.cinema.entity.Seats;

public class SeatsDao extends AbstractDao<Seats> {

	@Override
	public Seats findById(Long id) {
		Seats seats = null;
		try {
			Session session = HibernateUtil.getSessionFactory()
					.getCurrentSession();
			session.beginTransaction();
			seats = (Seats) session.get(Seats.class, id);
			session.getTransaction().commit();
		} catch (HibernateException exception) {
			exception.printStackTrace();
		}

		return seats;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Seats> findAll() {
		List<Seats> seats = null;
		try {
			Session session = HibernateUtil.getSessionFactory()
					.getCurrentSession();
			session.beginTransaction();
			seats = (List<Seats>) session.createCriteria(Seats.class).list();
			session.getTransaction().commit();
		} catch (HibernateException e) {

		}
		return seats;
	}


}
